package BehaviorModel.strategyModel;

/**
 * 功能描述: 策略模式 - 测试类
 * 2024/02/21
 * <p>
 * ZhangYi
 */
public class strategyModelClientTest {

    public static void main(String[] args){
        // 唐老鸭
        Duck tangDuck = new TangDuck("唐老鸭");
        tangDuck.setFlyBehavior(new NoFlyBehavior());
        tangDuck.fly();
        tangDuck.setSwimBehavior(new NoSwimBehavior());
        tangDuck.swim();

        //tangDuck.quack(); //Exception in thread "main" java.lang.RuntimeException: 唐老鸭 叫的行为没有指定实现类
        tangDuck.setQuackBehavior(new CanQuackBehavior());
        tangDuck.quack();

        // 狄高鸭
        Duck digoDuck = new DigoDuck("狄高鸭");
        //digoDuck.swim(); //Exception in thread "main" java.lang.RuntimeException: 狄高鸭 游泳的行为没有指定实现类
        digoDuck.setFlyBehavior(new NoFlyBehavior());
        digoDuck.fly();
        digoDuck.setQuackBehavior(new CanQuackBehavior());
        digoDuck.quack();

        // 北京鸭
        Duck beiJingDuck = new BeiJingDuck("北京鸭");
        beiJingDuck.setFlyBehavior(new NoFlyBehavior());
        beiJingDuck.fly();
        beiJingDuck.setSwimBehavior(new NoSwimBehavior());
        beiJingDuck.swim();
        beiJingDuck.setQuackBehavior(new NoQuackBehavior());
        beiJingDuck.quack();
    }
}
